package com.goose.bmm.controler.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTabHost;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBar.Tab;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;

import com.goose.bmm.R;
import com.goose.bmm.controler.adapter.SlidingMenuAdapter;
import com.goose.bmm.controler.fragment.EventLogFragment;
import com.goose.bmm.controler.fragment.ScoreBoardFragment;
import com.goose.bmm.controler.fragment.TotalGameFragment;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

public class MatchManagerActivity extends TabActivity implements
		OnClickListener, OnItemClickListener {

	private SlidingMenu mSlidingMenu;
	private ActionBar mActionBar;
	private Tab mTab1, mTab2, mTab3;
	private Fragment fragmentScoreBoard, fragmentTotalGame, fragmentEventLog;
	private ListView mListViewMenuLeft, mListViewMenuRight;

	private TabHost mTabHost;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_match_manager);

		// initialize tabs
		mTabHost = getTabHost();
		TabSpec tabScoreBoard = mTabHost.newTabSpec("SCORE BOARD");
		TabSpec tabTotalGame = mTabHost.newTabSpec("TOTAL GAME");
		TabSpec tabEventLog = mTabHost.newTabSpec("EVENT LOG");

		tabScoreBoard.setIndicator("SCORE BOARD");
		tabTotalGame.setIndicator("TOTAL GAME");
		tabEventLog.setIndicator("EVENT LOG");

		tabScoreBoard.setContent(new Intent(this, ScoreBoardActivity.class));
		tabTotalGame.setContent(new Intent(this, TotalGameActivity.class));
		tabEventLog.setContent(new Intent(this, EventLogActivity.class));

		mTabHost.addTab(tabScoreBoard);
		mTabHost.addTab(tabTotalGame);
		mTabHost.addTab(tabEventLog);

		// initialize sliding menu
		mSlidingMenu = new SlidingMenu(this);
		mSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
		mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

		mSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
		mSlidingMenu.setShadowDrawable(R.drawable.shadow_left);
		mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		mSlidingMenu.setFadeDegree(0.35f);
		mSlidingMenu.setBehindWidth(350);
		mSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
		mSlidingMenu.setMenu(R.layout.slide_menu_left);

		mSlidingMenu.setSecondaryMenu(R.layout.slide_menu_right);
		mSlidingMenu.setSecondaryShadowDrawable(R.drawable.shadow_right);
		// initialize menu
		mListViewMenuLeft = (ListView) mSlidingMenu.getMenu().findViewById(
				R.id.lv_menu_left);
		mListViewMenuLeft.setAdapter(new SlidingMenuAdapter(this));

		mListViewMenuRight = (ListView) mSlidingMenu.getSecondaryMenu()
				.findViewById(R.id.lv_menu_right);
		mListViewMenuRight.setAdapter(new SlidingMenuAdapter(this));

		// initialize view

	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_SHORT)
				.show();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		}
	}

}
